package com.avoid.easymqtt.common;

import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * 描述
 *
 * @author avoid@fiture.com
 * @date 2022/5/9
 * @motto Life is so short,do something to make yourself happy,such as coding
 */
public class RejectHandler implements RejectedExecutionHandler {

    private final String task;
    private final int maxBlockQueueSize;

    public RejectHandler(String task, int maxBlockQueueSize) {
        this.task = task;
        this.maxBlockQueueSize = maxBlockQueueSize;
    };

    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        throw new RejectedExecutionException(
            "Task:" + task + ",maxBlockQueueSize:" + maxBlockQueueSize + ",Thread:" + r.toString());
    }

}
